<template>
  <div class="hello">
    <div class="swiper-container">
      <div class="swiper-wrapper">
        <div class="swiper-slide" v-for="(v,i) in loops" :key="i">
          <img :src="v.image_800" alt />
        </div>
        <!-- <div class="swiper-slide">
          <img src="../../public/img_slides/02.jpg" alt />
        </div>
        <div class="swiper-slide">
          <img src="../../public/img_slides/03.jpg" alt />
        </div>
        <div class="swiper-slide">
          <img src="../../public/img_slides/04.jpg" alt />
        </div>-->
      </div>
      <!-- 如果需要分页器 -->
      <div class="swiper-pagination"></div>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
export default {
  props: {
    loops: {}
  },
  data() {
    return {};
  },
  watch: {
    loops() {
      this.$nextTick(() => {
        this.update();
      });
    }
  },
  methods: {
    initSwiper() {
      // var mySwiper = window.Swiper;
      this.$swiper=new Swiper(".swiper-container", {
        loop: true,
        //设置自动循环播放
        autoplay: true,
        // 如果需要分页器
        pagination: ".swiper-pagination",
        // 如果需要滚动条
        scrollbar: ".swiper-scrollbar"
      });
    },
    update() {
      this.$swiper.update();
    }
  },
  mounted() {
    this.initSwiper();
  }
};
</script>


<style scoped>
/* @import "../../public/css/swiper.min.css"; */
.hello {
  /* margin-top:100px; */
  /* background-color: #dedede; */
  display: flex;
  padding-top: 100px;
}
body {
  margin: 0;
  padding: 0;
}
.swiper-container {
  width: 100%;
  /* height: 400px; */
  /* margin: 20px auto; */
}
.swiper-slide > img {
  width: 100%;
  height: 100%;
}
</style>